home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / PInterfaces / ColorPicker.p < prev    next >
Encoding:
Text File  |  1994-07-17  |  3.2 KB  |  125 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        ColorPicker.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT ColorPicker;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __COLORPICKER__}
  27. {$SETC __COLORPICKER__ := 1}
  28.  
  29. {$I+}
  30. {$SETC ColorPickerIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __QUICKDRAW__}
  35. {$I Quickdraw.p}
  36. {$ENDC}
  37. {    Types.p                                                        }
  38. {        ConditionalMacros.p                                        }
  39. {    MixedMode.p                                                    }
  40. {    QuickdrawText.p                                                }
  41.  
  42. {$PUSH}
  43. {$ALIGN MAC68K}
  44. {$LibExport+}
  45.  
  46. CONST
  47. {Maximum small fract value, as long}
  48.     MaxSmallFract                = $0000FFFF;
  49.  
  50. { A SmallFract value is just the fractional part of a Fixed number,
  51. which is the low order word.  SmallFracts are used to save room,
  52. and to be compatible with Quickdraw's RGBColor.  They can be
  53. assigned directly to and from INTEGERs. }
  54. { Unsigned fraction between 0 and 1 }
  55.     
  56. TYPE
  57. SmallFract = INTEGER;
  58.  
  59. { For developmental simplicity in switching between the HLS and HSV
  60. models, HLS is reordered into HSL. Thus both models start with
  61. hue and saturation values; value/lightness/brightness is last. }
  62.     HSVColor = RECORD
  63.         hue:                    SmallFract;                                {Fraction of circle, red at 0}
  64.         saturation:                SmallFract;                                {0-1, 0 for gray, 1 for pure color}
  65.         value:                    SmallFract;                                {0-1, 0 for black, 1 for max intensity}
  66.     END;
  67.     HSLColor = RECORD
  68.         hue:                    SmallFract;                                {Fraction of circle, red at 0}
  69.         saturation:                SmallFract;                                {0-1, 0 for gray, 1 for pure color}
  70.         lightness:                SmallFract;                                {0-1, 0 for black, 1 for white}
  71.     END;
  72.     CMYColor = RECORD
  73.         cyan:                    SmallFract;
  74.         magenta:                SmallFract;
  75.         yellow:                    SmallFract;
  76.     END;
  77.  
  78. FUNCTION Fix2SmallFract(f: Fixed): SmallFract;
  79.     {$IFC NOT GENERATINGCFM}
  80.     INLINE $3F3C, $0001, $A82E;
  81.     {$ENDC}
  82. FUNCTION SmallFract2Fix(s: SmallFract): Fixed;
  83.     {$IFC NOT GENERATINGCFM}
  84.     INLINE $3F3C, $0002, $A82E;
  85.     {$ENDC}
  86. PROCEDURE CMY2RGB(cColor: CMYColor; VAR rColor: RGBColor);
  87.     {$IFC NOT GENERATINGCFM}
  88.     INLINE $3F3C, $0003, $A82E;
  89.     {$ENDC}
  90. PROCEDURE RGB2CMY(rColor: RGBColor; VAR cColor: CMYColor);
  91.     {$IFC NOT GENERATINGCFM}
  92.     INLINE $3F3C, $0004, $A82E;
  93.     {$ENDC}
  94. PROCEDURE HSL2RGB(hColor: HSLColor; VAR rColor: RGBColor);
  95.     {$IFC NOT GENERATINGCFM}
  96.     INLINE $3F3C, $0005, $A82E;
  97.     {$ENDC}
  98. PROCEDURE RGB2HSL(rColor: RGBColor; VAR hColor: HSLColor);
  99.     {$IFC NOT GENERATINGCFM}
  100.     INLINE $3F3C, $0006, $A82E;
  101.     {$ENDC}
  102. PROCEDURE HSV2RGB(hColor: HSVColor; VAR rColor: RGBColor);
  103.     {$IFC NOT GENERATINGCFM}
  104.     INLINE $3F3C, $0007, $A82E;
  105.     {$ENDC}
  106. PROCEDURE RGB2HSV(rColor: RGBColor; VAR hColor: HSVColor);
  107.     {$IFC NOT GENERATINGCFM}
  108.     INLINE $3F3C, $0008, $A82E;
  109.     {$ENDC}
  110. FUNCTION GetColor(where: Point; prompt: ConstStr255Param; inColor: RGBColor; VAR outColor: RGBColor): BOOLEAN;
  111.     {$IFC NOT GENERATINGCFM}
  112.     INLINE $3F3C, $0009, $A82E;
  113.     {$ENDC}
  114.  
  115. {$ALIGN RESET}
  116. {$POP}
  117.  
  118. {$SETC UsingIncludes := ColorPickerIncludes}
  119.  
  120. {$ENDC} {__COLORPICKER__}
  121.  
  122. {$IFC NOT UsingIncludes}
  123.  END.
  124. {$ENDC}
  125.